<template>
  <div>
       <el-table
      :data="seckillList"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column type="index" label="活动序号" >
      </el-table-column>
      <el-table-column prop="title" label="活动名称" >
      </el-table-column>
      <el-table-column  label="状态"> 
        <template v-slot="scoped">
          <div>
            <el-button type="success" v-if="scoped.row.status == 1">启 用</el-button>
            <el-button type="info" v-else>禁 用</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作"> 
        <template v-slot="scoped">
          <div>
            <el-button @click="update(scoped.row.id)">编 辑</el-button>
            <el-button @click="del(scoped.row.id)">删除</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import {seckdel} from "../../../request/api.js";
import { warningAlert,sucessAlert } from '../../../utils/alert';
export default {
  props: [],
  components: {},
  data() {
    return {};
  },
  computed: {
    ...mapGetters({
        seckillList:"seckill/list"
    }),
  },
  methods: {
    ...mapActions({
        seckAsyncList:"seckill/asynclist"
    }),
    update(id){
        this.$emit("update",id)
    },
    del(id){
        seckdel({id:id}).then(res=>{
        if(res.data.code == 200){
          sucessAlert(res.data.msg),
          this.seckAsyncList()
        }else{
          // 失败的提示窗
          warningAlert(res.data.msg)
          }
    })
  },
  },
  mounted() {
      this.seckAsyncList()
  },
};
</script>
<style scoped>
</style>